package tat.domain;

import java.util.HashSet;
import java.util.Observable;
import java.util.Set;


public class UseCaseRelation extends Relation {

    private Set<TatActor> actors;
    private TatUseCase useCase;
    
    public UseCaseRelation(final TatActor actor, final TatUseCase uc) {
        this.actors = new HashSet<TatActor>();
    	this.actors.add(actor);
        this.useCase = uc;
    }

    public TatActor actor() {
        return actors.iterator().next();
    }

    public boolean includesActor(final TatActor actor){
    	return actors.contains(actor);
    }
    
    public TatUseCase useCase() {
        return useCase;
    }

    /**
     * TODO Método mock.
     */
    @Override
    public Requirement requirement() {
    	//TODO complementar
        return new RelationRequirement("");
    }

	@Override
	public String name() {
		return "'" + useCase.name() + "  ENVOLVE  " + actors.iterator().next().name() + "'";
	}
	
	 public String toString() {
		 return "\t" + this.name() + "\n";
	 }

	 public String toXML() {
		 return "\t<use-case-model-relation>" + this.name() + "</use-case-model-relation>\n";
	 }


	@Override
	public void update(Observable o, Object arg) {
		this.setChanged();
		this.notifyObservers();
	}

}
